package com.mda.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * Created by Administrator on 13-12-8.
 */
public final class ExceptionUtils {
    public static String getTrack(Throwable t) {
        StringWriter sw = new StringWriter();
        PrintWriter writer = new PrintWriter(sw);
        t.printStackTrace(writer);
        StringBuffer buffer = sw.getBuffer();
        return buffer.toString();
    }

    public static String getTrack(Throwable t, String msg) {
        StringWriter sw = new StringWriter();
        PrintWriter writer = new PrintWriter(sw);
        new RuntimeException(msg, t).printStackTrace(writer);
        StringBuffer buffer = sw.getBuffer();
        return buffer.toString();
    }
}
